package es

import (
	"fmt"
	"github.com/elastic/go-elasticsearch/v7"
	"goods_srv/appconfig"
)

var (
	Es  *elasticsearch.Client
	err error
)

func InitEs() {
	res := appconfig.AppData.EsConfig

	cfg := elasticsearch.Config{
		Addresses: []string{
			fmt.Sprintf("%s:%d", res.Head, res.Pore),
		},
		// ...
	}
	Es, err = elasticsearch.NewClient(cfg)

	if err != nil {
		fmt.Println("es 连接失败", err)
		return
	}
	fmt.Println("es 连接成功", res)
}
